//
//  ViewController.m
//  NSThreadDemo
//
//  Created by UniHan_iMac on 17/3/29.
//  Copyright © 2017年 UniHan_iMac. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // NSThread 开辟分线程的三种方法
    NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(threadSelector) object:nil];
    thread.name = @"线程名称";
    // 开启线程
    [thread start];
    
    [NSThread detachNewThreadSelector:@selector(threadSelector) toTarget:self withObject:nil];
    
    [self performSelectorInBackground:@selector(threadSelector) withObject:nil];
}
- (void)threadSelector{
    // 设置线程休眠时间
    [NSThread sleepForTimeInterval:0.1];
    // 获取当前线程
    [NSThread currentThread];
    // 退出线程
    [NSThread exit];
    // 回到主线程
    [NSThread mainThread];
}
@end
